/*
 ============================================================================
 Name		: BlockHYBranch.h
 Author	  : Zhang Jiawei
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CBlockHYBranch declaration
 ============================================================================
 */

#ifndef BLOCKHYEXCHANGE_H
#define BLOCKHYEXCHANGE_H

// INCLUDES
#include "Block.h"
#include "MultilineListWidget.h"

class TExchangeInfo
{
public:
	TBuf<64>	iName;
	TBuf<128>	iAddress;
	TBuf8<32>	iTelQuery;
	TBuf8<32>	iTelDelgate;
};

// CLASS DECLARATION
class CBlockHYExchange: public CBlock, public MWidgetObserver
{
public:
    ~CBlockHYExchange();
    static CBlockHYExchange* NewL(CBaseBlock* bsBack = NULL);
    static CBlockHYExchange* NewLC(CBaseBlock* bsBack);
    
public:
    inline void SetReqID(TInt nReqID)
    {
    	iReqID = nReqID;
    };
    
public:
    void OnDraw(CFbsBitGc& g) const;

    void OnKeyDown(TInt keyCode);
    
    void OnMouseDown(const TPoint& aPt);
    
    void OnMouseMove(const TPoint& aPt);

    void OnMouseUp(const TPoint& aPt);

    void SizeChanged();
    void ChangeFocus(TBool aFoucs, const TInt& keyCode);
    
public:
    // from MWidgetObserver
    void UpdateScreen();
    void SelectOneRow(TInt aRowIndex);
    void LoseFocus(const TInt& keycode);
    
    void IntiList(RArray<TExchangeInfo>& aArray);
    
public:
	TBool GetHYURL(TDes8& aUri);
	TBool ParseJSONArray(const TDesC8& aJson);

private:
    CBlockHYExchange(CBaseBlock* bsBack);
    void ConstructL();
    TBool AppendNetworkData();
    
private:
	enum TNetworkStatus
	{
		ENetworkStatus_None,
		ENetworkStatus_Req
	};
    CMultilineListWidget*		iList;
    TInt				iNetworkStatus;
    
    RArray<TExchangeInfo>	iArray;
    TInt				iReqID;
};

#endif // BlockHYBranch_H
